/**
 * @author yexiebao
 * @date 2025/5/13
 */
public class RemoveElement {
    /**
     *暴力破解
     */
    public static int removeElement(int[]nums,int val){
        int length = nums.length;
        int i = 0;
        while(i < length){
            if(nums[i] == val){
                for(int j = i;j<length-1;j++){
                    nums[j] = nums[j+1];
                }
                length--;
            }
            else{
                i++;
            }
        }
        return nums.length;
    }
    /**
     * 双指针：快慢指针
     * 思路：好的覆盖好的
     */
    public static int removeElementUseDoublePoint(int[]nums,int val){
        int slow = 0;
        for (int fast = 0;fast < nums.length;fast++){
            if(nums[fast]!=val) {
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }

}